<?php

class Default_IndexController extends ExtLb_Controller_Action{
	
	private $menu2Tbl;
	private $postTbl;
	private $commentTbl;
	
	private $news;
	private $services;

    public function init(){
    	$this->loadCss('default', 'index', FOLDER_ROOT_NAME);
    	$this->loadLayout('default', 'layout');
    	
    
    	
    	$this->menu2Tbl	= new Admin_Model_Menu2();
    	$this->postTbl	= new Admin_Model_Posts();
    	$this->commentTbl = new Admin_Model_Comments();
    	
    }

    public function indexAction()
    {
    	//MENU 1 LA CO DINH
    	// MUC TIN TUC CO ID =3
    	$selectPostNews = $this->postTbl->selectPost("m2.menu1Id = 3 and bv.trangThai =1");
    	$paginatorPostNews = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($selectPostNews));
    	$paginatorPostNews->setItemCountPerPage(5);
    	$this->view->paginatorNews = $paginatorPostNews;

    	//
    	//DICH VU CO MENU1 ID = 4
    	$selectPostServices = $this->postTbl->selectPost("m2.menu1Id = 4 and bv.trangThai =1");
    	$paginatorPostServices = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($selectPostServices));
    	$paginatorPostServices->setItemCountPerPage(5);
    	$this->view->paginatorService = $paginatorPostServices;
    	
    	//RANDOM POST (BAI VIET NOI BAT)
    	$randPost = $this->postTbl->selectPost("bv.trangThai =1",'baiVietId DESC',10)->query()->fetchAll();
    	$this->view->randPosts = $randPost;
    	
    	$this->view->comments = $this->commentTbl->selectComment(NULL,'yKienId DESC',5)->query()->fetchAll();
        $this->view->title = "Ddddddddddddd";
    }


}

